package com.engine4cloud.tdf.education.convert;

import com.engine4cloud.tdf.common.core.util.CodeUtils;
import com.engine4cloud.tdf.education.dto.create.EduResourceCreateDTO;
import com.engine4cloud.tdf.education.dto.result.EduResourceResultDTO;
import com.engine4cloud.tdf.education.dto.update.EduResourceUpdateDTO;
import com.engine4cloud.tdf.education.entity.EduResourceEntity;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;


@Mapper
public interface EduResourceConvert {
    EduResourceConvert INSTANCE = Mappers.getMapper(EduResourceConvert.class);

    EduResourceEntity createTo(EduResourceCreateDTO s);

    EduResourceEntity update(EduResourceUpdateDTO s);

    EduResourceResultDTO convert(EduResourceEntity s);

    default EduResourceEntity create(EduResourceCreateDTO s, Long tenantId) {
        EduResourceEntity entity = createTo(s);
        entity.setTenantId(tenantId);
        entity.setCode(CodeUtils.entrustCode());
        return entity;
    }
}
